function newcoord=changecoord_5(s1, s2, s3, s4,a1, a2, a3, a4, a5)
  %Take a 5-D matrix A with s1=size(A,1), s2=size(A,2), s3=size(A,3),s4=size(A,4), s5=size(A,5)
  %Consider
  %B=reshape(A, s1*s2*s3*s4*s5,1);

  %Take the coordinates a1, a2, a3, a4, a5
  %This function gives the position in B of A(a1,a2,a3,a4,a5)
  newcoord = a1 + (a2-1 + (a3-1 + (a4-1 +(a5-1)*s4) *s3)*s2)*s1; 
  
end